let path = require('path')
const {md5} = require("./lib/topUtil");
require('dotenv').config({path: path.join(__dirname, '.env')})


const serverConfig = {
    clientConfig: {
        'appkey': process.env["AA_TB_APPKEY"],
        'appsecret': process.env["AA_TB_APPSECRET"],
        'url': `http://gw.api.taobao.com/router/rest`
    },
    defaultParamsConfig: {
        q: '促销',
        page_no: '1',
        page_size: '20',
        adzone_id: process.env["AA_TB_ADZONE_ID"],
        start_dsr: 48000,
        sort: "total_sales_des",
        material_id: 17004,
        has_coupon: true,
        need_prepay: true
    },
    apiConfig: [
        {
            code: 'searchApi',
            name: '物料搜索',
            url: 'taobao.tbk.dg.material.optional'
        },
        {
            code: 'recommendListApi',
            name: "物料精选升级版",
            url: 'taobao.tbk.dg.material.recommend'
        }, {
            code: 'materialSelectionApi',
            name: "物料精选",
            url: 'taobao.tbk.dg.optimus.material'
        },
        {
            code: "materialIds",
            name: "物料id获取",
            url: "taobao.tbk.optimus.tou.material.ids.get"
        }
    ],
    /**
     * @desc 获取到的设备信息生成对象返回
     * @param device_value 智能匹配-设备号加密后的值（MD5加密需32位小写） 物理地址 28:B2:BD:0A:10:3B
     * @param device_encrypt 智能匹配-设备号加密类型：MD5
     * @param device_type 智能匹配-设备号类型：IMEI，或者IDFA，或者UTDID（UTDID不支持MD5加密），或者OAID
     * @returns {{device_encrypt, device_value, device_type}}
     */
    getDeviceInfo(device_value, device_encrypt = 'MD5', device_type = 'IMEI') {
        if (device_value === undefined) return {}
        return {device_value: md5(device_value), device_encrypt, device_type}
    }
}


module.exports = serverConfig
